<?php

class IdeaController extends Application_Model_Controller
{
    /**
     * @var null|Application_Model_IdeaMapper
     */
    protected $mapper = null;

    public function init()
    {
        $this->view->headScript()->appendFile($this->view->baseUrl() . '/js/idea.js');
        $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/idea.css');
        $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/js/redactor/css/redactor.css', 'screen');
        $this->view->headScript()->appendFile($this->view->baseUrl()  . '/js/redactor/redactor.js');
        $this->view->headTitle('Планы');
        $this->view->tplSidebar = 'idea.phtml';
        $this->mapper = new Application_Model_IdeaMapper();
        $this->view->currentAction = $this->_getParam('type', Application_Model_Task::CURRENT);
    }

    public function indexAction()
    {
        $this->view->tasks = $this->mapper->getCollection(array('task_limit' => $this->view->currentAction, 'task_status' => Application_Model_Task::STATUS_OPEN), 'task_priority DESC');
    }

    public function calendarAction()
    {
        $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/js/fullcalendar/fullcalendar.css', 'screen');
        $this->view->headScript()->appendFile($this->view->baseUrl()  . '/js/fullcalendar/fullcalendar.js');
        $this->view->headScript()->appendFile($this->view->baseUrl()  . '/js/jquery-ui.custom.min.js');
        $this->view->currentAction = 'calendar';
    }
}
